package com.ideal.hbase.client.mapper.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;

import com.ideal.hbase.client.core.mapper.RowMapper;

public class TrasactionIdMapper implements RowMapper<List<String>>{

	@Override
	public List<String> mapRow(Result result, int rowNum) throws Exception {
		if (result.isEmpty()) {
            return Collections.emptyList();
        }
        final Cell[] rawCells = result.rawCells();
        final List<String> trasactionIdList = new ArrayList<>(rawCells.length);

        for (Cell cell : rawCells) {
            final String trasactionId = Bytes.toString(CellUtil.cloneQualifier(cell));
            trasactionIdList.add(trasactionId);
        }

        return trasactionIdList;
	}

}
